#include "SynTable.h"


SynTable::SynTable()
{
}


Id* SynTable::find(string name)
{
	SynTable* temp = this;
	while (temp!=NULL)
	{
		auto it = temp->table.find(name);
		if (it != temp->table.end())
		{
			return it->second;
		}
		temp = temp->prev;
	}
	return NULL;
}

bool SynTable::add(string name, Id* id)
{
	auto it = table.find(name);
	if (it == table.end())
	{
		table.insert(make_pair(name, id));
		return true;
	}
	return false;
}

SynTable::~SynTable()
{
}
